﻿Public MustInherit Class ItemRSSPage
    Inherits System.Web.UI.Page

    Protected MustOverride Function CreateDataGateway() As DataGateway

    Protected WithEvents RSSRepeater As Repeater

    Protected ReadOnly Property DefaultOrder() As OrderCriterion
        Get
            Return New OrderCriterion("CreatedDateTime", OrderCriterion.SortDirection.DESC)
        End Get
    End Property

    Protected Overridable Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        UpdateDataSource()
    End Sub

    Protected Overridable Sub UpdateDataSource()
        Dim gateway As DataGateway = CreateDataGateway()
        RSSRepeater.DataSource = gateway.FindAll(DefaultOrder)
        RSSRepeater.DataBind()
    End Sub

    Protected Function encodeHTML(text As String) As String
        Dim encoded As String
        encoded = HttpUtility.HtmlEncode(text)
        Return encoded
    End Function

    Protected Function getLeftPartURL() As String
        Return HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority)
    End Function
End Class
